var FG;
if (!FG)
    FG = {};

FG._colormapCache = {};
FG.getColormap = function(name) {
    if (_.has(FG._colormapCache, name)) {
        return FG._colormapCache[name]
    } else {
        var colormap = new FG.Colormap({id: name});
        colormap.fetch({async: false});
        FG._colormapCache[name] = colormap;
        return colormap;
    }
};

FG.Colormap = Backbone.Model.extend({
    urlRoot: '/api/fg/colormap'
});


FG.getDefaultCmap = function() {
    return FG.getSetting('plot.default_cmap', 'jet');
};

FG.getProperCmap = function(suggestion) {
    if (!!suggestion) {
        return FG.getSetting('plot.cmap_translate.' + suggestion, suggestion);
    } else {
        return FG.getDefaultCmap();
    }
};

